package com.ts.integral.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    //创建路由键交换机，处理需要增加积分的用户
    @Bean
    public DirectExchange integralExchange(){
        return new DirectExchange("point-Exchange",true,false);
    }

    //创建队列
    //注册成功的用户
    @Bean
    public Queue registerSucessQueue(){
        return new Queue("registersucess-Queue",true);
    }
    //帖子被评论的用户
    @Bean
    public Queue disscussQueue(){
        return new Queue("disscuss-Queue",true);
    }
    //发布帖子的用户
    @Bean
    public Queue publishPostQueue(){
        return new Queue("publishPost-Queue",true);
    }
    //完善用户信息的用户
    @Bean
    public Queue finishMessageQueue(){
        return new Queue("finishMessage-Queue",true);
    }
    //上传用户头像的用户
    @Bean
    public Queue uploadavatarQueue(){
        return new Queue("uploadavatar-Queue",true);
    }
    //被点赞的用户
    @Bean
    public Queue likeQueue(){
        return new Queue("like-Queue",true);
    }



    //绑定
    @Bean
    public Binding registerSucessQueueBindExchange(){
        return BindingBuilder.bind(registerSucessQueue()).to(integralExchange()).with("register");
    }
    @Bean
    public Binding disscussQueueBindExchange(){
        return BindingBuilder.bind(registerSucessQueue()).to(integralExchange()).with("discuss");
    }
    @Bean
    public Binding publishPostQueueBindExchange(){
        return BindingBuilder.bind(publishPostQueue()).to(integralExchange()).with("publishPost");
    }
    @Bean
    public Binding finishMessageQueueBindExchange(){
        return BindingBuilder.bind(finishMessageQueue()).to(integralExchange()).with("finishMessage");
    }
    @Bean
    public Binding uploadavatarQueueBindExchange(){
        return BindingBuilder.bind(uploadavatarQueue()).to(integralExchange()).with("uploadavatar");
    }
    @Bean
    public Binding likeQueueBindExchange(){
        return BindingBuilder.bind(likeQueue()).to(integralExchange()).with("like");
    }
}
